namespace TBlog.Web.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class produce : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Article",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Title = c.String(),
                        Author = c.String(),
                        Content = c.String(),
                        State = c.Int(nullable: false),
                        Tags = c.String(),
                        Hits = c.Int(nullable: false),
                        CategoryID = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Categorys", t => t.CategoryID, cascadeDelete: true)
                .Index(t => t.CategoryID);
            
            CreateTable(
                "dbo.Categorys",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        CategoryName = c.String(),
                        CreateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
            CreateTable(
                "dbo.Comment",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        UserEmail = c.String(),
                        CommentText = c.String(),
                        CommentIP = c.String(),
                        State = c.Int(nullable: false),
                        ArticleID = c.Int(nullable: false),
                        CreateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Article", t => t.ArticleID, cascadeDelete: true)
                .Index(t => t.ArticleID);
            
            CreateTable(
                "dbo.LoginLog",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        IP = c.String(),
                        CreateTime = c.DateTime(nullable: false),
                        UserID_ID = c.Int(),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Users", t => t.UserID_ID)
                .Index(t => t.UserID_ID);
            
            CreateTable(
                "dbo.Users",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        UserName = c.String(),
                        PassWord = c.String(),
                        CreateTime = c.DateTime(nullable: false),
                    })
                .PrimaryKey(t => t.ID);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.LoginLog", "UserID_ID", "dbo.Users");
            DropForeignKey("dbo.Comment", "ArticleID", "dbo.Article");
            DropForeignKey("dbo.Article", "CategoryID", "dbo.Categorys");
            DropIndex("dbo.LoginLog", new[] { "UserID_ID" });
            DropIndex("dbo.Comment", new[] { "ArticleID" });
            DropIndex("dbo.Article", new[] { "CategoryID" });
            DropTable("dbo.Users");
            DropTable("dbo.LoginLog");
            DropTable("dbo.Comment");
            DropTable("dbo.Categorys");
            DropTable("dbo.Article");
        }
    }
}
